package com.im.service.folderManage.smo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.im.service.folderManage.dao.IFolderManageQueryDAO;
import com.im.util.JsonUtil;
import com.im.util.ReturnsUtil;
import com.im.viewmodel.folderManage.FolderInfoManageRespVo;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.im.service.common.dao.ICommonDAO;
import com.im.service.dto.BusiConstParamVal;
import com.im.service.dto.DocInfo;
import com.im.service.dto.FileBorrow;
import com.im.service.dto.FileUpload;
import com.im.service.dto.ImplementProject;
import com.im.service.dto.PageQuery;
import com.im.service.dto.ProjectStage;
import com.im.service.dto.StageNode;

@Service
public class IFolderManageQuerySMOImpl implements IFolderManageQuerySMO{
	
	@Autowired
	private IFolderManageQueryDAO folderManageQueryDAO;
	@Autowired
	private ICommonDAO commoDao;

	@Override
	public List<ProjectStage> queryImpleProjStageList(Map<String, Object> param) {
		return folderManageQueryDAO.queryImpleProjStageList(param);
	}

	@Override
	public List<StageNode> queryStageNodeList(Map<String, Object> param) {
		return folderManageQueryDAO.queryStageNodeList(param);
	}

	@Override
	public FileUpload queryFileUploadInfo(Map<String, Object> param) {
		return folderManageQueryDAO.queryFileUploadInfo(param);
	}

	@Override
	public DocInfo queryDocInfoInfo(Map<String, Object> param) {
		return folderManageQueryDAO.queryDocInfoInfo(param);
	}

	@Override
	public FileUpload queryFileUploadInfoDetail(Map<String, Object> param) {
		return folderManageQueryDAO.queryFileUploadInfoDetail(param);
	}

	@Override
	public DocInfo queryDocInfoInfoDetail(Map<String, Object> param) {
		return folderManageQueryDAO.queryDocInfoInfoDetail(param);
	}

	@Override
	public List<StageNode> queryStageChildNodeList(Map<String, Object> param) {
		return folderManageQueryDAO.queryStageChildNodeList(param);
	}

	@Override
	public ProjectStage queryImpleProjStageByProjStageId(Map<String, Object> param) {
		return folderManageQueryDAO.queryImpleProjStageByProjStageId(param);
	}

	@Override
	public FileBorrow queryFileBorrowInfoDetail(Map<String, Object> param) {
		return folderManageQueryDAO.queryFileBorrowInfoDetail(param);
	}

	@Override
	public List<DocInfo> queryDocInfoByProjStageId(Map<String, Object> param) {
		return folderManageQueryDAO.queryDocInfoByProjStageId(param);
	}

	@Override
	public int selectDocInfoByParamCount(Map<String, Object> param) {
		return folderManageQueryDAO.selectDocInfoByParamCount(param);
	}

	@Override
	public int selectUploadFileByParamCount(Map<String, Object> param) {
		return folderManageQueryDAO.selectUploadFileByParamCount(param);
	}

	@Override
	public PageQuery<FolderInfoManageRespVo> queryProjectStageDocInfo(String inJson) {
		PageQuery<FolderInfoManageRespVo> page = JsonUtil.jsonToBean(inJson, PageQuery.class);
		PageHelper.startPage(page.getPageNumber(), page.getPageSize());
		List<FolderInfoManageRespVo> respVoList = new ArrayList<FolderInfoManageRespVo>();
		String impleProjId = JsonUtil.obtainValueFromJsonObject(inJson, "impleProjId");
		String planProjId = JsonUtil.obtainValueFromJsonObject(inJson, "planProjClass");
		String orgId = JsonUtil.obtainValueFromJsonObject(inJson, "orgId");
		String fileAttr = JsonUtil.obtainValueFromJsonObject(inJson, "fileAttr");
		String option = JsonUtil.obtainValueFromJsonObject(inJson, "option");
		
		int docInfoTotal = 0;
		int borrowedTotal = 0;
		int nomFileTotal = 0;
		int keyFileTotal = 0;
		Map<String, Object> docParam = new HashMap<String, Object>();
		List<String> impleProjIdList = new ArrayList<String>();
		List<String> projStageIdList = new ArrayList<String>();
		List<DocInfo> docInfoList = new ArrayList<DocInfo>();
		if((orgId != null && !"".equals(orgId)) 
				|| (planProjId != null && !"".equals(planProjId)) 
				|| (impleProjId != null && !"".equals(impleProjId))){
			Map<String, Object> impleProJMap = new HashMap<String, Object>();
			impleProJMap.put("impleProjId", impleProjId);
			impleProJMap.put("planProjClass", planProjId);
			impleProJMap.put("orgId", orgId);
			List<ImplementProject> implementProjectList = folderManageQueryDAO.queryImpleProjListForDocInfo(impleProJMap);
			if(implementProjectList.size() > 0){
				for(ImplementProject proj : implementProjectList){
					impleProjIdList.add(proj.getImpleProjId());
				}
				Map<String, Object> stageMap = new HashMap<String, Object>();
				stageMap.put("impleProjIds", impleProjIdList);
				List<ProjectStage> projStageList = folderManageQueryDAO.queryProjStageByImpleProjIds(stageMap);
				if(projStageList.size() > 0){
					for(ProjectStage stageBean : projStageList){
						projStageIdList.add(stageBean.getProjStageId());
					}
					docParam.put("projStageIds", projStageIdList);
					docParam.put("docSourceType", "40");
					docParam.put("fileAttr", fileAttr);
					docInfoList = folderManageQueryDAO.queryDocInfoByProjStageId(docParam);
				}
			}
		}else{
			docParam.put("docSourceType", "40");
			docParam.put("fileAttr", fileAttr);
			docInfoList = folderManageQueryDAO.queryDocInfoByProjStageId(docParam);
		}
//		Map<String, Object> paramMap = new HashMap<String, Object>();
//		paramMap.put("impleProjId", impleProjId);
//		paramMap.put("planProjClass", planProjId);
//		paramMap.put("orgId", orgId);
		
		
		if (docInfoList.size() > 0) {
			for (DocInfo docInfo : docInfoList) {
				FolderInfoManageRespVo respVo = new FolderInfoManageRespVo();
				String projStageId = docInfo.getDocObjId();
				Map<String, Object> stageMap = new HashMap<String, Object>();
				stageMap.put("projStageId", projStageId);
				ProjectStage projStage = folderManageQueryDAO.queryProjStageByProjStageId(stageMap);
				if(projStage != null){
					respVo.setProjectStage(projStage);
					respVo.setImpleProjId(projStage.getImpleProjId());
					respVo.setImpleProjName(projStage.getImpleProjName());
				}
				
				respVo.setDocInfo(docInfo);
					if("stats".equals(option) || "borrow".equals(option)){
						if (docInfo.getStatusCd().equals(20)) {
							Map<String, Object> borrowMap = new HashMap<String, Object>();
							FileBorrow fileBorrowInfo = new FileBorrow();
							fileBorrowInfo.setDocInfoId(docInfo.getDocInfoId());
							borrowMap.put("fileBorrowInfo", fileBorrowInfo);
							FileBorrow fileBorrow = folderManageQueryDAO.queryFileBorrowInfoDetail(borrowMap);
							respVo.setFileBorrow(fileBorrow);
						}
						if("stats".equals(option)){
							Map<String, Object> param = new HashMap<String, Object>();
							param.put("impleProjId", impleProjId);
							param.put("planProjClass", planProjId);
							//统计文件总数
							docInfoTotal = folderManageQueryDAO.selectDocInfoByParamCount(param);
							//统计借出文档总数statusCd =20
							param.put("statusCd", 20);
							borrowedTotal = folderManageQueryDAO.selectDocInfoByParamCount(param);
							//统计一般文件总数fileAttr =10
							param.put("fileAttr", 10);
							nomFileTotal = folderManageQueryDAO.selectUploadFileByParamCount(param);
							//统计关键文件总数fileAttr =20
							param.put("fileAttr", 20);
							keyFileTotal = folderManageQueryDAO.selectUploadFileByParamCount(param);
							respVo.setDocInfoTotal(docInfoTotal);
							respVo.setBorrowedTotal(borrowedTotal);
							respVo.setNomFileTotal(nomFileTotal);
							respVo.setKeyFileTotal(keyFileTotal);
						}
						Map<String, Object> docUploadMap = new HashMap<String, Object>();
						docUploadMap.put("uploadObjId", docInfo.getDocInfoId());
						docUploadMap.put("uploadObjType", "90");
						docUploadMap.put("fileAttr", fileAttr);
						
						List<FileUpload> fileUploadInfos = folderManageQueryDAO.queryFileUploadInfoList(docUploadMap);
						if (fileUploadInfos.size() > 0) {
							respVo.setUploadInfos(fileUploadInfos);
						}
					}else{
						Map<String, Object> docUploadMap = new HashMap<String, Object>();
						docUploadMap.put("uploadObjId", docInfo.getDocInfoId());
						docUploadMap.put("uploadObjType", "90");
						List<FileUpload> fileUploadInfos = folderManageQueryDAO.queryFileUploadInfoList(docUploadMap);
						if (fileUploadInfos.size() > 0) {
							respVo.setUploadInfos(fileUploadInfos);
						}
					}
					respVoList.add(respVo);
			}
		}
//		List<ImplementProject> implementProjectList = folderManageQueryDAO.queryImpleProjListForDocInfo(paramMap);
//		if(implementProjectList.size() > 0){
//			for(ImplementProject impPorject : implementProjectList){
//				Map<String, Object> stageMap = new HashMap<String, Object>();
//				stageMap.put("impleProjId", impPorject.getImpleProjId());
//				List<ProjectStage> projStageList = folderManageQueryDAO.queryProjStageByImpleProjId(stageMap);
//				if(projStageList.size() > 0){
//					for(ProjectStage projStage : projStageList){
//						String projStageClass = projStage.getProjStageClass();
//						String projStageId = projStage.getProjStageId();
//						Map<String, Object> docParam = new HashMap<String, Object>();
//						docParam.put("docObjId", projStageId);
//						docParam.put("docSourceType", "40");
//						docParam.put("fileAttr", fileAttr);
//						List<DocInfo> docInfoList = folderManageQueryDAO.queryDocInfoByProjStageId(docParam);
//						if (docInfoList.size() > 0) {
//							for (DocInfo docInfo : docInfoList) {
//								FolderInfoManageRespVo respVo = new FolderInfoManageRespVo();
//								respVo.setImpleProjId(impPorject.getImpleProjId());
//								respVo.setImpleProjName(impPorject.getImpleProjName());
//								respVo.setProjectStage(projStage);
//								respVo.setDocInfo(docInfo);
//									if("stats".equals(option) || "borrow".equals(option)){
//										if (docInfo.getStatusCd().equals(20)) {
//											Map<String, Object> borrowMap = new HashMap<String, Object>();
//											FileBorrow fileBorrowInfo = new FileBorrow();
//											fileBorrowInfo.setDocInfoId(docInfo.getDocInfoId());
//											borrowMap.put("fileBorrowInfo", fileBorrowInfo);
//											FileBorrow fileBorrow = folderManageQueryDAO.queryFileBorrowInfoDetail(borrowMap);
//											respVo.setFileBorrow(fileBorrow);
//										}
//										if("stats".equals(option)){
//											Map<String, Object> param = new HashMap<String, Object>();
//											param.put("impleProjId", impleProjId);
//											param.put("planProjClass", planProjId);
//											//统计文件总数
//											docInfoTotal = folderManageQueryDAO.selectDocInfoByParamCount(param);
//											//统计借出文档总数statusCd =20
//											param.put("statusCd", 20);
//											borrowedTotal = folderManageQueryDAO.selectDocInfoByParamCount(param);
//											//统计一般文件总数fileAttr =10
//											param.put("fileAttr", 10);
//											nomFileTotal = folderManageQueryDAO.selectUploadFileByParamCount(param);
//											//统计关键文件总数fileAttr =20
//											param.put("fileAttr", 20);
//											keyFileTotal = folderManageQueryDAO.selectUploadFileByParamCount(param);
//											respVo.setDocInfoTotal(docInfoTotal);
//											respVo.setBorrowedTotal(borrowedTotal);
//											respVo.setNomFileTotal(nomFileTotal);
//											respVo.setKeyFileTotal(keyFileTotal);
//										}
//										Map<String, Object> docUploadMap = new HashMap<String, Object>();
//										docUploadMap.put("uploadObjId", docInfo.getDocInfoId());
//										docUploadMap.put("uploadObjType", "90");
//										docUploadMap.put("fileAttr", fileAttr);
//										
//										List<FileUpload> fileUploadInfos = folderManageQueryDAO.queryFileUploadInfoList(docUploadMap);
//										if (fileUploadInfos.size() > 0) {
//											respVo.setUploadInfos(fileUploadInfos);
//										}
//									}else{
//										Map<String, Object> docUploadMap = new HashMap<String, Object>();
//										docUploadMap.put("uploadObjId", docInfo.getDocInfoId());
//										docUploadMap.put("uploadObjType", "90");
//										List<FileUpload> fileUploadInfos = folderManageQueryDAO.queryFileUploadInfoList(docUploadMap);
//										if (fileUploadInfos.size() > 0) {
//											respVo.setUploadInfos(fileUploadInfos);
//										}
//									}
//									respVoList.add(respVo);
//							}
//					}
//				}
//			}
//		}
		PageInfo pageInfo = new PageInfo(respVoList);
		page.setRows(respVoList);
		page.setTotalPages(pageInfo.getPages());
		page.setTotal(pageInfo.getTotal());
		return page;
	}

	@Override
	public JSONArray queryDocInfoByProjStageId(String inJson) {
		JSONArray returnList = new JSONArray();
		String projStageId = JsonUtil.obtainValueFromJsonObject(inJson, "projStageId");
		String fileAttr = JsonUtil.obtainValueFromJsonObject(inJson, "fileAttr");
		String option = JsonUtil.obtainValueFromJsonObject(inJson, "option");
		String parentId = JsonUtil.obtainValueFromJsonObject(inJson, "parentId");

		if(projStageId != null && !"".equals(projStageId)){
			Map<String, Object> stageMap = new HashMap<String, Object>();
			ProjectStage projectStage = new ProjectStage();
			projectStage.setProjStageId(projStageId);
			stageMap.put("projStage", projectStage);
			ProjectStage pStage = folderManageQueryDAO.queryImpleProjStageByProjStageId(stageMap);

			Map<String, Object> param = new HashMap<String, Object>();
			param.put("docObjId", projStageId);
			param.put("docSourceType", "40");
			param.put("fileAttr", fileAttr);
			List<DocInfo> docInfoList = folderManageQueryDAO.queryDocInfoByProjStageId(param);

			if (docInfoList.size() > 0) {
				for (DocInfo docInfo : docInfoList) {
					JSONObject nodeJson = new JSONObject();
//					stageMap.put("projStage", projectStage);
					if (pStage != null) {
						nodeJson.put("impleProjId", pStage.getImpleProjId());
						nodeJson.put("impleProjName", pStage.getImpleProjName());
						nodeJson.put("projectStage", pStage);
						nodeJson.put("projStateName", pStage.getProjStateName());
					}
					nodeJson.put("_parentId", parentId);
					nodeJson.put("id", docInfo.getDocInfoId());
					nodeJson.put("level", "3");
					if (docInfo != null) {
						nodeJson.put("docInfo", docInfo);
						nodeJson.put("statusCdName", docInfo.getStatusCdName());
						if("stats".equals(option) || "borrow".equals(option)){
							if (docInfo.getStatusCd().equals(20)) {
								Map<String, Object> borrowMap = new HashMap<String, Object>();
								FileBorrow fileBorrowInfo = new FileBorrow();
								fileBorrowInfo.setDocInfoId(docInfo.getDocInfoId());
								borrowMap.put("fileBorrowInfo", fileBorrowInfo);
								FileBorrow fileBorrow = folderManageQueryDAO.queryFileBorrowInfoDetail(borrowMap);
								nodeJson.put("fileBorrow", fileBorrow);
							}
							
//							FileUpload fileUpload = new FileUpload();
//							fileUpload.setUploadObjId(docInfo.getDocInfoId());
//							fileUpload.setUploadObjType("90");
//							fileUpload.setFileAttr(fileAttr);
							
							Map<String, Object> docUploadMap = new HashMap<String, Object>();
//							docUploadMap.put("fileUpload", fileUpload);
							docUploadMap.put("uploadObjId", docInfo.getDocInfoId());
							docUploadMap.put("uploadObjType", "90");
							docUploadMap.put("fileAttr", fileAttr);
							
							List<FileUpload> fileUploadInfos = folderManageQueryDAO.queryFileUploadInfoList(docUploadMap);
//							if (fileUploadInfos.size() > 0) {
//								nodeJson.put("uploadInfo", fileUploadInfos);
//							}
							if (fileUploadInfos.size() > 0) {
								nodeJson.put("uploadInfo", fileUploadInfos);
//								for(FileUpload fUpload : fileUploadInfos){
//									nodeJson.put("uploadInfo", fUpload);
//									returnList.add(nodeJson);
//								}
							}
//							if (fileUploadInfo != null) {
//								nodeJson.put("uploadInfo", fileUploadInfo);
//							}
						}else{
//							FileUpload fileUpload = new FileUpload();
//							fileUpload.setUploadObjId(docInfo.getDocInfoId());
//							fileUpload.setUploadObjType("90");
							Map<String, Object> docUploadMap = new HashMap<String, Object>();
//							docUploadMap.put("fileUpload", fileUpload);
							docUploadMap.put("uploadObjId", docInfo.getDocInfoId());
							docUploadMap.put("uploadObjType", "90");
							List<FileUpload> fileUploadInfos = folderManageQueryDAO.queryFileUploadInfoList(docUploadMap);
							if (fileUploadInfos.size() > 0) {
								nodeJson.put("uploadInfo", fileUploadInfos);
//								for(FileUpload fUpload : fileUploadInfos){
//									nodeJson.put("uploadInfo", fUpload);
//									returnList.add(nodeJson);
//								}
							}
//							FileUpload fileUploadInfo = folderManageQueryDAO.queryFileUploadInfo(docUploadMap);
//							if (fileUploadInfo != null) {
//								nodeJson.put("uploadInfo", fileUploadInfo);
//							}
						}
					}
					returnList.add(nodeJson);
				}
			}
		}
		return returnList;
	}

	@Override
	public String queryFileInfoDetail(String inJson) {
		String docInfoId = JsonUtil.obtainValueFromJsonObject(inJson, "docInfoId");
		Map<String, Object> docMap = new HashMap<String, Object>();
		DocInfo doc = new DocInfo();
		doc.setDocInfoId(docInfoId);
		docMap.put("docInfo", doc);
		DocInfo docInfo = folderManageQueryDAO.queryDocInfoInfoDetail(docMap);
		FileUpload fileUploadInfo = folderManageQueryDAO.queryFileUploadInfoDetail(docMap);
		JSONObject returnJson = new JSONObject();
		returnJson.put("docInfo", docInfo);
		returnJson.put("fileUploadInfo", fileUploadInfo);
		return ReturnsUtil.returnSuccess(returnJson).toString();
	}
	
	@Override
	public PageQuery<ImplementProject> queryImpleProjListForDocInfo(String inJson) {
		PageQuery<ImplementProject> page = JsonUtil.jsonToBean(inJson, PageQuery.class);
		PageHelper.startPage(page.getPageNumber(), page.getPageSize());
		String impleProjId = JsonUtil.obtainValueFromJsonObject(inJson, "impleProjId");
		String planProjId = JsonUtil.obtainValueFromJsonObject(inJson, "planProjClass");
		String orgId = JsonUtil.obtainValueFromJsonObject(inJson, "orgId");
		String option = JsonUtil.obtainValueFromJsonObject(inJson, "option");
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("impleProjId", impleProjId);
		paramMap.put("planProjClass", planProjId);
		paramMap.put("orgId", orgId);
		
		List<ImplementProject> implementProjectList = folderManageQueryDAO.queryImpleProjListForDocInfo(paramMap);
		if(implementProjectList.size() > 0){
			for(ImplementProject impPorject : implementProjectList){
				impPorject.set_parentId("");
				impPorject.setId(UUID.randomUUID().toString());
				impPorject.setLevel("1");
			}
		}
		
		int docInfoTotal = 0;
		int borrowedTotal = 0;
		int nomFileTotal = 0;
		int keyFileTotal = 0;
		
		if("stats".equals(option)){
			Map<String, Object> param = new HashMap<String, Object>();
//			param.put("projStageId", projStageId);
			param.put("impleProjId", impleProjId);
			param.put("planProjId", planProjId);
//			param.put("planProjClass", planProjClass);
			//统计文件总数
			docInfoTotal = folderManageQueryDAO.selectDocInfoByParamCount(param);
			//统计借出文档总数statusCd =20
			param.put("statusCd", 20);
			borrowedTotal = folderManageQueryDAO.selectDocInfoByParamCount(param);
			//统计一般文件总数fileAttr =10
			param.put("fileAttr", 10);
			nomFileTotal = folderManageQueryDAO.selectUploadFileByParamCount(param);
			//统计关键文件总数fileAttr =20
			param.put("fileAttr", 20);
			keyFileTotal = folderManageQueryDAO.selectUploadFileByParamCount(param);
		}
		
		if("stats".equals(option)){
			ImplementProject implementProjectStats= new ImplementProject();
			//如果是统计新增增加一个新节点
			implementProjectStats.set_parentId("");
			implementProjectStats.setId("static");
			implementProjectStats.setProjStateName("统计信息");
			implementProjectStats.set_parentId(null);
			implementProjectStats.setState("open");
			implementProjectStats.setDocInfoTotal(docInfoTotal);
			implementProjectStats.setBorrowedTotal(borrowedTotal);
			implementProjectStats.setKeyFileTotal(keyFileTotal);
			implementProjectStats.setNomFileTotal(nomFileTotal);
			implementProjectList.add(implementProjectStats);
		}
		
		PageInfo pageInfo = new PageInfo(implementProjectList);
		page.setRows(implementProjectList);
		page.setTotalPages(pageInfo.getPages());
		page.setTotal(pageInfo.getTotal());
		return page;
	}

	@Override
	public List<BusiConstParamVal> queryProjectStageForDocInfo(String inJson) {
		String impleProjId = JsonUtil.obtainValueFromJsonObject(inJson, "impleProjId");
		String parentId = JsonUtil.obtainValueFromJsonObject(inJson, "parentId");
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("impleProjId", impleProjId);
		List<ProjectStage> projStageList = folderManageQueryDAO.queryProjStageByImpleProjId(paramMap);
		Map<String, Object> constMap = new HashMap<String, Object>();
		constMap.put("constParamId", "10001");
		List<BusiConstParamVal> projStageConstList = commoDao.queryBusiConstValByCond(constMap);
		for(BusiConstParamVal constParam : projStageConstList){
			constParam.setId(UUID.randomUUID().toString());
			constParam.set_parentId(parentId);
			constParam.setLevel("2");
		}
		if(projStageList.size() > 0){
			for(ProjectStage projStage : projStageList){
				String projStageClass = projStage.getProjStageClass();
				String projStageId = projStage.getProjStageId();
				for(BusiConstParamVal constParam : projStageConstList){
					String paramValValue = constParam.getParamValValue();
					if(projStageClass.equals(paramValValue)){
						constParam.setProjStageId(projStageId);
						break;
					}
				}
			}
		}
		return projStageConstList;
	}

//	@Override
//	public PageQuery<FolderInfoManageRespVo> queryProjectStageDocInfo(String inJson) {
//		PageQuery<FolderInfoManageRespVo> page = JsonUtil.jsonToBean(inJson, PageQuery.class);
//		PageHelper.startPage(page.getPageNumber(), page.getPageSize());
//		List<FolderInfoManageRespVo> respVoList = new ArrayList<FolderInfoManageRespVo>();
//		String impleProjId = JsonUtil.obtainValueFromJsonObject(inJson, "impleProjId");
//		String planProjId = JsonUtil.obtainValueFromJsonObject(inJson, "planProjClass");
//		String orgId = JsonUtil.obtainValueFromJsonObject(inJson, "orgId");
//		String fileAttr = JsonUtil.obtainValueFromJsonObject(inJson, "fileAttr");
//		String option = JsonUtil.obtainValueFromJsonObject(inJson, "option");
//		
//		int docInfoTotal = 0;
//		int borrowedTotal = 0;
//		int nomFileTotal = 0;
//		int keyFileTotal = 0;
//		
//		Map<String, Object> paramMap = new HashMap<String, Object>();
//		paramMap.put("impleProjId", impleProjId);
//		paramMap.put("planProjClass", planProjId);
//		paramMap.put("orgId", orgId);
//		
//		List<ImplementProject> implementProjectList = folderManageQueryDAO.queryImpleProjListForDocInfo(paramMap);
//		if(implementProjectList.size() > 0){
//			for(ImplementProject impPorject : implementProjectList){
//				Map<String, Object> stageMap = new HashMap<String, Object>();
//				stageMap.put("impleProjId", impPorject.getImpleProjId());
//				List<ProjectStage> projStageList = folderManageQueryDAO.queryProjStageByImpleProjId(stageMap);
//				if(projStageList.size() > 0){
//					for(ProjectStage projStage : projStageList){
//						String projStageClass = projStage.getProjStageClass();
//						String projStageId = projStage.getProjStageId();
//						Map<String, Object> docParam = new HashMap<String, Object>();
//						docParam.put("docObjId", projStageId);
//						docParam.put("docSourceType", "40");
//						docParam.put("fileAttr", fileAttr);
//						List<DocInfo> docInfoList = folderManageQueryDAO.queryDocInfoByProjStageId(docParam);
//						if (docInfoList.size() > 0) {
//							for (DocInfo docInfo : docInfoList) {
//								FolderInfoManageRespVo respVo = new FolderInfoManageRespVo();
//								respVo.setImpleProjId(impPorject.getImpleProjId());
//								respVo.setImpleProjName(impPorject.getImpleProjName());
//								respVo.setProjectStage(projStage);
//								respVo.setDocInfo(docInfo);
//									if("stats".equals(option) || "borrow".equals(option)){
//										if (docInfo.getStatusCd().equals(20)) {
//											Map<String, Object> borrowMap = new HashMap<String, Object>();
//											FileBorrow fileBorrowInfo = new FileBorrow();
//											fileBorrowInfo.setDocInfoId(docInfo.getDocInfoId());
//											borrowMap.put("fileBorrowInfo", fileBorrowInfo);
//											FileBorrow fileBorrow = folderManageQueryDAO.queryFileBorrowInfoDetail(borrowMap);
//											respVo.setFileBorrow(fileBorrow);
//										}
//										if("stats".equals(option)){
//											Map<String, Object> param = new HashMap<String, Object>();
//											param.put("impleProjId", impleProjId);
//											param.put("planProjClass", planProjId);
//											//统计文件总数
//											docInfoTotal = folderManageQueryDAO.selectDocInfoByParamCount(param);
//											//统计借出文档总数statusCd =20
//											param.put("statusCd", 20);
//											borrowedTotal = folderManageQueryDAO.selectDocInfoByParamCount(param);
//											//统计一般文件总数fileAttr =10
//											param.put("fileAttr", 10);
//											nomFileTotal = folderManageQueryDAO.selectUploadFileByParamCount(param);
//											//统计关键文件总数fileAttr =20
//											param.put("fileAttr", 20);
//											keyFileTotal = folderManageQueryDAO.selectUploadFileByParamCount(param);
//											respVo.setDocInfoTotal(docInfoTotal);
//											respVo.setBorrowedTotal(borrowedTotal);
//											respVo.setNomFileTotal(nomFileTotal);
//											respVo.setKeyFileTotal(keyFileTotal);
//										}
//										Map<String, Object> docUploadMap = new HashMap<String, Object>();
//										docUploadMap.put("uploadObjId", docInfo.getDocInfoId());
//										docUploadMap.put("uploadObjType", "90");
//										docUploadMap.put("fileAttr", fileAttr);
//										
//										List<FileUpload> fileUploadInfos = folderManageQueryDAO.queryFileUploadInfoList(docUploadMap);
//										if (fileUploadInfos.size() > 0) {
//											respVo.setUploadInfos(fileUploadInfos);
//										}
//									}else{
//										Map<String, Object> docUploadMap = new HashMap<String, Object>();
//										docUploadMap.put("uploadObjId", docInfo.getDocInfoId());
//										docUploadMap.put("uploadObjType", "90");
//										List<FileUpload> fileUploadInfos = folderManageQueryDAO.queryFileUploadInfoList(docUploadMap);
//										if (fileUploadInfos.size() > 0) {
//											respVo.setUploadInfos(fileUploadInfos);
//										}
//									}
//									respVoList.add(respVo);
//							}
//						}
//					}
//				}
//			}
//		}
//		PageInfo pageInfo = new PageInfo(respVoList);
//		page.setRows(respVoList);
//		page.setTotalPages(pageInfo.getPages());
//		page.setTotal(pageInfo.getTotal());
//		return page;
//	}
}
